Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
@babel/plugin-transform-async-to-generator
Advanced tools
Turn async functions into ES2015 generators
The @babel/plugin-transform-async-to-generator package is a Babel plugin that transforms async functions into generator functions using the regenerator runtime, which is a part of the Facebook Regenerator project. This transformation allows async functions to be used in environments that do not natively support async/await syntax by converting them into ES2015/ES6 compatible code.
Transform async functions to generators
This feature allows developers to write asynchronous code using the modern async/await syntax and have it transformed into generator functions that are compatible with older JavaScript engines.
async function foo() {
await bar();
}
// Transforms to:
function foo() {
return regeneratorRuntime.async(function foo$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return regeneratorRuntime.awrap(bar());
case 2:
case "end":
return _context.stop();
}
}
}, null, this);
}
This package is similar to @babel/plugin-transform-async-to-generator in that it transforms async functions, but it does so by delegating to a specified module method, allowing for custom handling of async functions.
Fast-async is a Babel plugin that uses nodent to transform async/await functions. It is designed to be faster than the regenerator-based approach used by @babel/plugin-transform-async-to-generator and does not require a runtime.
While not a direct alternative, babel-preset-env includes the capability to transform async functions when the target environments specified do not support them natively. It uses @babel/plugin-transform-async-to-generator as part of its transformation suite when necessary.
Turn async functions into ES2015 generators
See our website @babel/plugin-transform-async-to-generator for more information.
Using npm:
npm install --save-dev @babel/plugin-transform-async-to-generator
or using yarn:
yarn add @babel/plugin-transform-async-to-generator --dev
v7.25.9 (2024-10-22)
babel-parser
, babel-template
, babel-types
syntacticPlaceholders
mode (@liuxingbaoyu)babel-helper-compilation-targets
, babel-preset-env
ClassAccessorProperty
to prevent the no-undef
rule (@victorenator)babel-parser
, babel-types
VISITOR_KEYS
etc. faster to access (@liuxingbaoyu)FAQs
Turn async functions into ES2015 generators
The npm package @babel/plugin-transform-async-to-generator receives a total of 24,011,152 weekly downloads. As such, @babel/plugin-transform-async-to-generator popularity was classified as popular.
We found that @babel/plugin-transform-async-to-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.